﻿<?php
require_once(dirname(__FILE__)."/../../libs/login/login.php"); 
require_once(dirname(__FILE__)."/../../libs/dbclass/dbconnect.php");
require_once(dirname(__FILE__)."/../../libs/string/libstr.php");
require_once(dirname(__FILE__)."/../../libs/string/pager.php");
require_once(dirname(__FILE__)."/../../admin/libs/article_class.php");
$lg=new login();
$lg->checklogin("admin_member");//检验是否登录
$mc=new libstr();
$ar=new article();
$pg=new pager();
//执行操作 使用js提交的
if($mc->Ismp($_POST["cz"])!=""){
if($_POST["cz"]==-3){
	$ar->article_del($_POST["items"]);
}else{
	$ar->updateisshow($_POST["items"],$_POST["cz"]);
}

}
//更改文章状态
if($mc->Ismp($_GET["actid"])!=""){
	$items=array($_GET["actid"]); //
	$status=$_GET["status"];
	$ar->updateisshow($items,$status);
	$mc->msg("","article_list.php?classid=".$_GET["classid"]."&isshow=".$_GET["isshow"]);
}


//获得文章列表
$string="*";//选中项
$cataid=$_GET["classid"];
if($_GET["keyname"]=="topicname"){
	$topicname=$_GET["keyvalue"];
}
if($_GET["keyname"]=="codeid"){
	$codeid=$_GET["keyvalue"];
}


$isshow="";
if($mc->Ismp($_GET["isshow"]!=""))$isshow=$_GET["isshow"];
$order="id";
$sj="desc";
if($mc->Ismp($_GET["sj"]!=""))$sj=$_GET["sj"];
$pagesize=15;
if($mc->Ismp($_GET["pagesize"]!=""))$pagesize=$_GET["pagesize"];
$page=1;
if($mc->Ismp($_GET["page"]!=""))$page=$_GET["page"];
$getstr=$ar->articlelist($string,$cataid,$topicname,$codeid,$isshow,$order,$sj,$pagesize,$page);
//分页

$totalcount_xiaoquan=$getstr[0]["totalcount"];
$totalcount=$totalcount_xiaoquan;
$pg->isre=false;
	$pindex="";

	$getpp=$pg->fsarr($pg->fstr($pindex,$totalcount,$pagesize,6,""));
	$ptxt="";
	foreach ($getpp as $pagers)
	{
		if($pagers["color"]!="true")
		{
			$ptxt .="<li ><a href='".$pagers["url"]."' >".$pagers["index"]."</a></li>";
		}else
		{
			$ptxt .="<li class=\"ea\"><a href='javascript:;' >".$pagers["index"]."</a></li>";
		}
	}
	if($totalcount>0){
		$pagetext="<li> <a href='".$pg->next($pg->pp($pindex,$totalcount,$pagesize,"",""))."'><img src='../images/leftjt.jpg' width='10' height='11' /></a></li> ".$ptxt."  <li><a href='".$pg->next($pg->np($pindex,$totalcount,$pagesize,"",""))."'><img src='../images/yightjt.jpg' width='10' height='11' /></a></li>";
	}
	if($pagesize>=$totalcount){$pagetext="";}

$path="文章列表";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="../css/css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript">
//搜素列表
function mbsearch(){
	$("#mbsearch").submit();	
}
//全选操作
function checkall(){
	
   if($("#checkedAll").attr("checked") == true){ //check all
	  $("input[name='items[]']").each(function(){
		 $(this).attr("checked",true);
	   });
	
	}else{
	 $("input[name='items[]']").each(function(){
		 $(this).attr("checked",false);
	  });
   }
}

//执行操作多个
function zhixing(){
	if($("input[type=checkbox][name='items[]']:checked").length==0){
		alert("您还没选中任何资源！");
		return;
	}
if(confirm("您确定要执行所选项？")){
	$("#czform").submit();
	return;
	}
}

</script>
</head>
<body style="background:#fff"> 

<div class="content">
    <div class="right">
   <table width="100%" border="0" cellspacing="0" cellpadding="0">
   	<tr>
        <td width="100%" height="24" class="top_head">&nbsp;</td>
      </tr>
      <tr>
        <td valign="top">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="1%" align="right"  height="45">&nbsp;</td>
                <td width="99%" >
                 <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="55%" style="padding-left:20px;padding-top:10px;"><img src="../images/head.gif" width="13" height="11"><b><?php echo $path;?></b><a href="article_add.php?classid=<?php echo $_GET["classid"];?>" style=" margin-left:20px; text-decoration:underline;">添加文章</a></td>
                    <td width="45%" align="right">&nbsp;</td>
                  </tr>
                </table>
                </td>
              </tr>
            </table>
        </td>
      </tr>
      <tr>
        <td>
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="bg">
          <tr >
            <td valign="middle"  style=" padding:5px 0 5px 0;" >
            	<table width="92%"  border="0" cellspacing="0" align="center">
                	<tr>
                    	<td width="20%" align="left">
                        	<Div class="xuanxiang">
                                <input type="submit" name="button" id="button" value="发布中" onclick="location.href='article_list.php'" <?php if($_GET["isshow"]==""){?>class="active"<?php }?>/>
                               <!-- <input type="submit" name="button" id="button" value="已下架" onclick="location.href='article_list.php?isshow=-1'" <?php if($_GET["isshow"]=="-1"){?>class="active" <?php }?>/>-->
                                <input type="submit" name="button" id="button" value="回收站" onclick="location.href='article_list.php?isshow=-2'"<?php if($_GET["isshow"]=="-2"){?>class="active" <?php }?> />
                             </Div>
                        </td>
                    	<td width="80%">
                        	<div class="xuanze">
                              <form method="GET" action="" id="mbsearch">
                              <Span> 
                              <select name="classid" onChange="location.href='<?=$PHP_SELF?>?sj=<?php echo $sj?>+&pagesize=<?php echo $pagesize?>&classid=' + this.options[this.selectedIndex].value">
                                <option value="">全部分类</option>
                                  <?php 
									$db->depth=0;
									$twhere="";  
									$db->getchild("article_class",0,$mc->Ismp($_GET["classid"]),"ID","&nbsp;&nbsp;",$twhere);
									
									?>
                              </select>
                              </Span>
                              <!-- <span>
                                   <select name="keyname">
                                    <option value="topicname" <?php if($mc->Ismp($_GET['keyname'])=="topicname"){?>selected<?php }?>>文章标题</option>
                                    <option value="codeid" <?php if($mc->Ismp($_GET['codeid'])=="15"){?>selected<?php }?>>文章编号</option>
                                  </select>
                               </span>-->
                              <!--<input name="keyvalue" type="text" value="<?php echo $_GET["keyvalue"]?>"/>-->
                              
                              <Span>
                                  <select name="sj" onChange="location.href='<?=$PHP_SELF?>?sj=' + this.options[this.selectedIndex].value+'&pagesize=<?php echo $pagesize?>&classid=<?php echo $mc->Ismp($_GET["classid"])?>'" > 
                                    <option value="desc" <?php if($sj=="desc"){?>selected<?php }?>>降序</option>
                                    <option value="asc" <?php if($sj=="asc"){?>selected<?php }?>>升序</option>
                                  </select>
                              </Span>
                                   <Span>
                                   <select name="pagesize" onChange="location.href='<?=$PHP_SELF?>?sj=<?php echo $sj?>+&pagesize=' + this.options[this.selectedIndex].value+'&classid=<?php echo $mc->Ismp($_GET["classid"])?>'">
                                    <option value="15" <?php if($pagesize=="15"){?>selected<?php }?>>15条</option>
                                    <option value="20" <?php if($pagesize=="20"){?>selected<?php }?>>20条</option>
                                    <option value="30" <?php if($pagesize=="30"){?>selected<?php }?>>30条</option>
                                </select></Span>
                             <span><!--<input type="submit" name="search" id="search" value="提交"  onclick="mbsearch()"/></span>-->
                              </form>
                          </div>
                        </td>
                    </tr>
                </table>
             </td>
          </tr>
      
      <tr>
      	<td valign="middle" align="center" >
             <table width="92%"   border="1px" bordercolor="#ccc" cellspacing="0px" style="border-collapse:collapse">
                  <thead align="center" bgcolor="#EEEEEE">
                    <tr>
                    	<th  width="3%" height="28" align="left"  >&nbsp;</th>
                        <th  width="5%" height="28" align="left"  >序号</th>
                        <th  width="26%" height="28" align="left" style="padding-left:1%;">文章名称</th>
                        <th width="10%" height="28" align="center">文章编号</th>
                        <th width="15%" height="28" align="center">文章类别</th>
                        <th width="10%" height="28" align="center">状态</th>
                        <th width="19%" height="28" align="center">发布时间</th>
                        <th width="25%" colspan="2" align="center">操作</th>
                    </tr>
                  </thead>
              <tbody>
               <form action="" method="POST" id="czform">
                <?php if(count($getstr)>0){
					 $autoid=1; ?>   
              <?php foreach ($getstr as $rs){?>
              	<tr align="center" bgcolor="#FFFFFF">
                	<td  height="28" align="center"><input name="items[]" type="checkbox" value="<?php echo $rs["id"];?>" /></td>
                    <td  height="28" align="center"><?php echo ($getpp['index']-0)*$pagesize+$autoid?></td>
                	<td  align="left" style="padding-left:1%;"><a href="#"><?php echo $rs["topicname"]?></a> </td>
                	 <td height="28" align="center"><?php echo $rs["codeid"];?></td>
                    <td height="28" align="center"><?php echo $ar->getclassname($rs["rootid"]);?></td>
                    <td height="28" align="center"><?php echo $ar->showzhuangtai($rs["isshow"]);?></td>
                    <td height="28" align="center"><?php echo $mc->gettime($rs["createtime"]);?></td>
                    <td height="28" colspan="2" align="center">
                    <bdo><input type="button" name="button8" id="button8" value="修改" onclick="location.href='article_edit.php?id=<?php echo $rs["id"];?>'"/></bdo>
                    <?php if($isshow==-2){?>
                   		<bdo><input type="button" name="button8" id="deleteone" value="还原" onclick="if(confirm('您确定还原本项吗?')){location.href='?actid=<?php echo $rs["id"];?>&classid=<?php echo $_GET["classid"];?>&status=1&isshow=<?php echo $_GET["isshow"];?>'}"/></bdo>
                    <?php }else{?>
                    	<bdo><input type="button" name="button8" id="deleteone" value="删除" onclick="if(confirm('您确定删除本项吗?')){location.href='?actid=<?php echo $rs["id"];?>&classid=<?php echo $_GET["classid"];?>&status=-2&isshow=<?php echo $_GET["isshow"];?>'}"/></bdo>
                    <?php }?>
                    </td>
                </tr>
            <?php 
						$autoid++;
					} 
						
				}else{?>
             <tr align="center" bgcolor="#FFFFFF">
               
                    <td height="30" colspan="8" align="center">对不起，暂时找不到相关资源！</td>
                    
                </tr>
                <?php }?>
              <?php if($pagetext!=""){?>
                  <tr align="center" bgcolor="#FFFFFF">
                  <td height="40" align="center">&nbsp;</td>
                  <td height="40" align="center">&nbsp;</td>
              	  <td height="40" align="left">&nbsp;</td>
              	  <td height="50" colspan="4" align="right" valign="middle"><ul><?php echo $pagetext;?></ul></td>
                  </tr>
                    <?php }?>
                   <tr align="center" bgcolor="#FFFFFF"> 
                      <td height="28" align="center"  ><input type="checkbox" value="checkbox" id="checkedAll" name="checkedAll" onclick="checkall()"></td>
                      <td height="28" align="left" colspan="7">
                         <select name="cz" id="select">
                            <!--<option value="1">上架</option>
                            <option  value="-1" >下架</option>-->
                            <option  value="-2">删除</option>
                            <option  value="-3">彻底删除</option>
                            <option value="1">还原回收</option>
                         </select> 
                        <input type="button" name="czbtn" id="czbtn" value="执行" onclick="zhixing()" class="czbtn"/></td>
                  </tr>
                  </form>
              </tbody>
            </table>
            </td>
          </tr>
        </table>
        </td>
      </tr>
    </table>
    </div>
</div>
</body>
</html>